/**
* Vista asociada al contenido 
* del tab de la funcionalidad VER VIDEO
* en el aplicativo.
*/
Ext.define("entgpv11.view.details.VideoList", {
    extend: "Ext.Container",
    alias: "widget.videolist",
	requires: ["Ext.Video"
	],
    config: { 
	    fullscreen: true,
        layout: 'fit'
    },
	initialize: function() {
	    try
        {
			this.callParent();
			this.listComponent = {
			    xtype: 'list',
				itemTpl: '<div>{name}</div>',
				id: 'video-list',
				loadingText: "Cargando datos...",
				emptyText: "<center><div class=\"notes-list-empty-text\">Datos no encontrados</div></center>",
				store: Ext.getStore("ListVideo"),
				grouped: true,
				indexBar: true,
				onItemDisclosure: true,
				hidden: false,
				height: "90%",
				listeners: {
				    disclose: { fn: this.onListItemTap, scope: this}//itemtap
				}
			};
			this.myVideo =  {
					xtype    : 'video',
					x:0,
					y:20,
					id: 'my-video-player',
					hidden: true,
					height: "90%",
					loop: false,
                    url :"",					
					//url      : "http://localhost:8080/entgpall/resources/load/BigBuck.m4v",
					posterUrl: "./resources/images/video/screenshot01.png" ,
					listeners: {
						stop: {fn:this.onStop,scope: this}
					}
					
			};
			//this is a navigationlist and am pushing a panel to display the video
            //to the video something like this http://youtube.com/whatch?v=[video_id]&feature=youtube_gdata
			this.myFrame = Ext.create('Ext.Panel', {
					xtype: 'panel',
					id:'video-frame',
					hidden: true,
					height: "90%",
					margin:"0 10 10 0"
			});
		
			this.add([
			         {
                            xtype: 'toolbar',
                            docked: 'top',
                            ui: 'sub',
                            title: 'Videos',
                            items: [

                                          {
                                              xtype: "button",
                                              hidden: true,
                                              id:"buttonBackVideo",
                                              iconMask: true,
                                              pressed: true,
                                              iconCls: 'doc_send_1',
                                              handler: this.onVideoButtonTap,
                                              scope: this
                                          },
                                          { xtype: 'spacer' }

                                   ]
                     },
			         this.listComponent,
					 this.myVideo,
					 this.myFrame
					
					]);


        
        //this.onAfter('erased', function(){ this.destroy(); });
        
        }catch(ex)
		{
		    APP_GLOBAL.SetLog('VideoList.initialize::' + ex);
		}	
	},
    addContainerItems: function (record) {
	   try
	   {
	        var n =0;
			var customerListStore =Ext.getStore("ListVideo");
			//APP_GLOBAL.SetProxyExtraParam(customerListStore, "id", _id);
			//customerListStore.load();
			customerListStore.setData(record);
			n=customerListStore.getCount();
			return(n);
	   }
		catch(ex)
		{
		    APP_GLOBAL.SetLog(ex);
		}
    },
	//onListItemTap: function (me, index,target, record, evt,  eOpts) {
    onListItemTap: function (list, record, target, index, evt, options) {
        this.fireEvent('listItemTapCommand', this, list, record);
    },
    onVideoButtonTap: function () {
        this.fireEvent('videoButtonCommand',this);
    }
	
});

